<template>


  <el-descriptions class="margin-top" title="融资企业" :column="1" :size="size" border>

    <template slot="extra">
      <el-button type="primary" size="small" @click="addTender()">发起标的</el-button>
      <el-button type="primary" size="small">修改</el-button>
    </template>
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-user"></i>
        企业名称
      </template>
      {{tableData.enterpriseName}}
    </el-descriptions-item>
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-user"></i>
        法人
      </template>
      {{tableData.legal}}
    </el-descriptions-item>
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-mobile-phone"></i>
        法人手机号
      </template>
      {{tableData.legalPhone}}
    </el-descriptions-item>
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-user"></i>
        法人身份证号
      </template>
      {{tableData.legalId}}
    </el-descriptions-item>
    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-picture-outline"></i>
        营业执照照片
      </template>
      <img :src="serverUrl" style="width:200px; height:150px">

    </el-descriptions-item>

    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-wallet"></i>
        注册资金
      </template>
      {{tableData.registeredCapital+'元'}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-wallet"></i>
        企业资金
      </template>
      {{tableData.businessCapital+'元'}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-wallet"></i>
        企业冻结资金
      </template>
      {{tableData.frozenCapital+'元'}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-location-outline"></i>
        核心企业审核状态
      </template>
      {{tableData.coreState}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-location-outline"></i>
        平台审核状态
      </template>
      {{tableData.platformState}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-smoking"></i>
        等级评分
      </template>
      <el-rate v-model="value2" :colors="colors">
      </el-rate>
    </el-descriptions-item>

  </el-descriptions>

</template>

<script>
  export default {
    data() {
      return {
        value1: null,
        value2: null,
        colors: ['#99A9BF', '#F7BA2A', '#FF9900'],  // 等同于 { 2: '#99A9BF', 4: { value: '#F7BA2A', excluded: true }, 5: '#FF9900' }
        serverUrl: '',
        size: '',
        userName: '',
        EnterpriseName: '',
        pageNum: 1,
        pageSize: 5,
        total: 0,
        tableData: {
          enterpriseId: '',
          enterpriseName: '',
          legal: '',
          legalPhone: '',
          legalId: '',
          businessLicenseImage: '',
          businessLicense: '',
          registeredCapital: 0,
          businessCapital: 0,
          frozenCapital: 0,
          coreState: '',
          platformState: ''
        },
        selectionData: [],
        ischeck: false,
        data: [],
        userMenuId: [],
        // label:树图显示内容
        userId: '',

      }
    },

    methods: {

      deleteFinance(id) {
        let jwt = localStorage.getItem('jwt')
        this.$axios.get('api/finance/removeRolePermission?id=' + id, { headers: { 'jwt': jwt } })
          .then(res => {
            console.log(res.data)
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
            } else {
              this.$message({
                type: 'info',
                message: '删除失败'
              });
            }
          })
      },

      prevPage(val) {
        this.pageNum = val;
        //alert(val)
        this.queryFinance();

      },
      nextPage(val) {
        this.pageNum = val;
        //alert(val)
        this.queryFinance();
      },
      changePage(val) {
        this.pageNum = 1;
        this.pageSize = val;
        //alert(val)
        this.queryFinance();
      },
      queryBtn() {
        this.pageNum = 1;
        this.queryFinance();
      },


      queryUserId() {
        let userName = localStorage.getItem("userName")
        let jwt = localStorage.getItem("jwt");
        this.$axios.get('api/finance/user/getUserIdByUserName?userName=' + userName, { headers: { 'jwt': jwt } })
          .then(res => {

            if (res.data.code == 200) {
              console.log(res.data)
            }
          })
      },
      queryEnterpriseId() {
        let userName = localStorage.getItem("userName")
        let jwt = localStorage.getItem("jwt");
        this.$axios.get('api/finance/user/getEnterpriseIdByUserName?userName=' + userName, { headers: { 'jwt': jwt } })
          .then(res => {
            if (res.data.code == 200) {
              localStorage.setItem("enterpriseId", res.data.data)

            }
          })
      },
      queryFinance() {

        let jwt = localStorage.getItem("jwt");
        let enterpriseId = localStorage.getItem("enterpriseId")
        this.$axios.get('api/finance/findFinanceById?enterpriseId=' + enterpriseId, { headers: { 'jwt': jwt } })
          .then(res => {
            if (res.data.code == 200) {
              this.tableData = res.data.data
              this.serverUrl = res.data.data.businessLicenseImage
            }
          })
      },
      addTender() {
        this.$router.push('addTender')

      },
      handleSelectionChange(val) {
        //每行数据
        console.log(val);
        this.selectionData = val;
      },

    },

    created() {
      this.queryUserId()
      this.queryEnterpriseId()
      this.queryFinance()
    }
  }
</script>


<style scoped>
  .el-row {
    margin-top: 20px;
  }
</style>